{{ if isset site.Params "favicon" }}
<link href="{{ site.Params.favicon | relURL }}" rel="icon" type="image/x-icon" />
{{ end }}

<link rel="canonical" href="{{ .Permalink }}" />

{{ if eq .Type "posts" }}
<!-- Page Author & Description -->
<meta name="author" content="{{ if isset .Params "author" }}{{ .Params.author }}{{ else }}{{ site.Params.author }}{{ end }}" />
<meta name="description" content="{{ .Summary | plainify }}" />

<!-- Keywords -->
{{- $keywords := slice }}
{{- with .Keywords }}
  {{- $keywords = . }}
{{- else }}
  {{- range .GetTerms "tags" }}
    {{- $keywords = $keywords | append .Title }}
  {{- else }}
    {{- range $taxonomy, $_ := site.Taxonomies }}
      {{- range $.GetTerms $taxonomy }}
        {{- $keywords = $keywords | append .Title }}
      {{- end }}
    {{- end }}
  {{- end }}
{{- end }}
<meta name="keywords" content="{{ delimit $keywords `,` }}">
{{ else }}
<!-- Site Author & Description -->
<meta name="author" content="{{ site.Params.author }}" />
<meta name="description" content="{{ site.Params.description | plainify }}" />
{{ end }}

<!-- Site Generator -->
{{ hugo.Generator }}

<!-- Open Graph -->
{{ template "_internal/opengraph.html" . }}

<!-- Twitter Cards -->
{{ template "_internal/twitter_cards.html" . }}

{{ $outputCss := resources.Get "css/output.css" }}
{{ if hugo.IsProduction }}
  {{ $outputCss = $outputCss | minify }}
{{ end }}
<link rel="stylesheet" href="{{ $outputCss.RelPermalink }}" />

{{ if or site.Params.backgroundImage site.Params.backgroundImageDark }}
<style>
{{ if site.Params.backgroundImage }}
#dream-global-bg {
  background-image: url({{ site.Params.backgroundImage | relURL }});
}
{{ end }}

{{ if site.Params.backgroundImageDark }}
html.dark #dream-global-bg {
  background-image: url({{ site.Params.backgroundImageDark | relURL }});
}
{{ end }}
</style>
{{ end }}
